﻿
function goBack() {
    location.href = "/MeetRoom/RoomList";
}
function SubData() {
    var postData = {
        RoomID: $("#hid").val(),
        ProvinceID: $("#ProvinceSelect").val(),
        CityID: $("#citylist").val(),
        RoomName: $("#RoomName").val().trim(),
        IsActive: $("#PIsActive").val(),
        DetailAddress: $("#dAddress").val().trim(),
        CreateTime: $("#hidCreateTime").val(),
        CreateUserID: $('#hidCreateUserID').val(),
        Remark: HtmlUtil.htmlEncodeByRegExp(CKEDITOR.instances.desTextarea.getData())
    };

    //使用异步进行修改数据的信息
    $.post("/MeetRoom/Updateinfo", postData, function (date) {
        if (date == "suc") {
            //关闭层，刷新表单
            goBack();
        }
        else if (date == "repeat") {
            $.alert({
                title: '系统提示',
                content: '重复数据无法保存！',
                confirm: function () {
                }
            });
        }
        else if (date == "nouser") {
            location.href = '/Login/Index';
        }
        else {
            $.alert({
                title: '系统提示',
                content: '操作失败',
                confirm: function () {
                }
            });
        }
    });
}


$(document).ready(function () {
    $("#rightResources").addClass("active");
    CKEDITOR.replace('desTextarea', {
        toolbar: 'Basic'
        //uiColor: '#9AB8F3'//界面颜色
    });
    CKEDITOR.instances.desTextarea.setData(HtmlUtil.htmlDecodeByRegExp($('#hidCom').val()));
    $('#RoomUpdateForm')
  .bootstrapValidator({
      message: 'This value is not valid',
      feedbackIcons: {
          valid: 'glyphicon glyphicon-ok',
          invalid: 'glyphicon glyphicon-remove',
          validating: 'glyphicon glyphicon-refresh'
      },
      fields: {
          ProvinceSelect: {
              message: 'The Province is not valid',
              validators: {
                  notEmpty: {
                      message: 'The Province is required and can\'t be empty'
                  }
              }
          },
          citylist: {
              message: 'The City is not valid',
              validators: {
                  notEmpty: {
                      message: 'The City is required and can\'t be empty'
                  }
              }
          },
          RoomName: {
              message: 'The Meeting Room Name is not valid',
              validators: {
                  notEmpty: {
                      message: 'The Meeting Room Name is required and can\'t be empty'
                  }
              }
          },
          dAddress: {
              message: 'The Detail Address is not valid',
              validators: {
                  notEmpty: {
                      message: 'The Detail Address is required and can\'t be empty'
                  }
              }
          }
      }
  })
  .on('success.form.bv', function (e) {
      e.preventDefault();
      SubData();
  });
});
